#-*- encoding: utf-8-*-

'''
Created on 2012-1-10

@author: Botao Wu
'''

from xml.etree.ElementTree import XML

def parse(xml, parser):
    tree = XML(xml, parser)
    
    for ele in tree:
        print 'tag: ', ele.tag.strip()
        print 'text: ', ele.text.strip()
        print 'attrib: ', ele.attrib
        for child in ele:
            print child.tag.strip()
            print child.text.strip()
            print child.attrib


xml='''<root>
    <group>
    <child id="a">This is child "a"</child>
    <child id="b">This is child "a"</child>
    </group>
    <group>
    <child id="c">This is child "c"</child>
    <child id="d">This is child "d"</child>
    </group>
</root>'''


parse(xml, None)